home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2004 April
/
CMCD0404.ISO
/
Software
/
Shareware
/
Programare
/
sharp
/
wwwSharp_setup.exe
/
{app}
/
Examples
/
TreeView
/
Assembly
/
TreeView.cs
next >
Wrap
Text File
|
2003-12-04
|
2KB
|
92 lines
using System.Reflection;
using System;
using System.Windows.Forms;
using mshtml;
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyKeyFile("")]
namespace wwwSharp.ClrHost.Examples
{
public class TreeView: System.Windows.Forms.TreeView
{
public TreeView(): base()
{
}
private IHTMLElement m_OutputControl = null;
public IHTMLElement OutputControl
{
get {return m_OutputControl;}
set {m_OutputControl = value;}
}
public void FillTreeView()
{
// Display a wait cursor while the TreeNodes are being created.
Cursor.Current = Cursors.WaitCursor;
// Suppress repainting the TreeView until all the objects have been created.
BeginUpdate();
try
{
// Clear the TreeView each time the method is called.
Nodes.Clear();
// Add 1000 nodes to the tree.
for (int i = 1; i <= 10; i++)
{
TreeNode node = Nodes.Add("Node " + i.ToString());
for (int j = 1; j <= 10; j++)
{
TreeNode child = node.Nodes.Add("Child " + j.ToString());
for (int k = 1; k <= 10; k++)
child.Nodes.Add("Subchild " + k.ToString());
}
}
}
finally
{
// Reset the cursor to the default for all controls.
Cursor.Current = Cursors.Default;
// Begin repainting the TreeView.
EndUpdate();
}
}
protected override void OnAfterSelect(TreeViewEventArgs e)
{
base.OnAfterSelect(e);
//Send output to HTML control.
if (m_OutputControl != null)
{
if (e.Node != null)
{
string strFullNodeName = e.Node.Text;
TreeNode node = e.Node.Parent;
while (node != null)
{
strFullNodeName = node.Text + "/" + strFullNodeName;
node = node.Parent;
}
m_OutputControl.innerText = "Selected node: " + strFullNodeName;
}
else
m_OutputControl.innerText = "";
}
}
}
}